﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace OpenComposite.SOBADesigner
{
	internal partial class FormApplicationError : Form
	{
		protected FormApplicationError()
		{
			InitializeComponent();
		}

		internal FormApplicationError(string title, string message, string details, bool showExit)
			: this()
		{
			this.Text = title;
			this.txtMsg.Text = message;
			this.txtDetails.Text = details;
			this.btnExit.Visible = showExit;
		}

		private void btnOK_Click(object sender, EventArgs e)
		{
			this.DialogResult = DialogResult.OK;
			this.Close();
		}
		private void btnExit_Click(object sender, EventArgs e)
		{
			this.DialogResult = DialogResult.Abort;
			this.Close();
		}

		private void btnCopyToClipboard_Click(object sender, EventArgs e)
		{
			Clipboard.Clear();
			Clipboard.SetText(
				string.Format("{1}{0}{0}{2}{0}{0}{3}",
				Environment.NewLine, this.Text, this.txtMsg.Text, this.txtDetails.Text));
		}

	}

	internal static class ApplicationError
	{
		internal static DialogResult Show(string title, string message, string details, bool showExit)
		{
			FormApplicationError frm = new FormApplicationError(title, message, details, showExit);
			frm.TopMost = true;
			return frm.ShowDialog();
		}
	}

}
